package com.woniuxy.controller;

import com.woniuxy.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Controller
public class Controller_three {
    @RequestMapping("/Array")
    public ModelAndView show(String username,String password,String[] hobby){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username",username);
        modelAndView.addObject("password",password);
        modelAndView.addObject("msg", Arrays.toString(hobby));
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }

    @RequestMapping("/list")
    public ModelAndView show(String username, String password, @RequestParam List<String> hobby){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("username",username);
        modelAndView.addObject("password",password);
        modelAndView.addObject("msg", hobby);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }

    @RequestMapping("/map")
    public ModelAndView show(@RequestParam Map<String,Object> info, @RequestParam List<String> hobby){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg", info+","+hobby);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }

    @RequestMapping("/Object")
    public ModelAndView show(User user){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("msg",user);
        modelAndView.setViewName("/WEB-INF/jsp/show.jsp");
        return modelAndView;
    }

}
